package cn.git.shiro.exception;

import cn.git.shiro.result.Result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @description: 全局异常处理，现在只标记权限校验失败处理
 * @program: bank-credit-sy
 * @author: lixuchun
 * @create: 2024-03-27
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * UnauthorizedException 权限验证失败处理器
     * @param e
     * @return
     */
    @ResponseBody
    @ExceptionHandler(Exception.class)
    public Result Exception(Exception e) {
        return Result.error(e.getMessage());
    }

}
